﻿
@using WHLRDF.Application.Model;
@model UserEntity

@{

    ViewData["Title"] = "用户 编辑";
    Layout = "../Shared/_Layout.cshtml";

}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content text-center p-md">
                    <form id="dynamic-form" asp-action="Edit" method="post" class="form-horizontal" role="form">
                        <div class="form-group">
                            <label class="col-md-3"></label>
                            <div class="col-md-9  text-left">
                                <div class="input-group m-b">
                                    <div asp-validation-summary="@ValidationSummary.All" class=" text-danger text-left"></div>
                                </div>
                            </div>
                        </div>
                        <input type="hidden" asp-for="UserId" />

                        <div class="form-group">
                            <label asp-for="UserName" class="col-md-3 control-label text-right"> 用户名称</label>
                            <div class="col-md-9 text-left ">
                                <div class="input-group m-b">
                                    <span class="input-group-addon">*</span>
                                    <input asp-for="UserName" class="form-control" validate="{required:true  ,maxlength:16,validuser:true,remote:{url:'../../account/ChkUserName',data:{UserId:function(){return $('#UserId').val(); }}}}" />
                                </div>
                                <span asp-validation-for="UserName" class="text-danger"></span>
                            </div>


                        </div>
                        <div class="form-group">
                            <label asp-for="Phone" class="col-md-3 control-label text-right"> 电话</label>
                            <div class="col-md-9  text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon"></span>
                                    <input asp-for="Phone" class="form-control" validate="{required:false  ,maxlength:20,remote:{url:'../../account/ChkPhone',data:{UserId:function(){return $('#UserId').val(); }}},phoneUS:true  }" />
                                </div>
                                <span asp-validation-for="Phone" class="text-danger"></span>
                            </div>


                        </div>
                        <div class="form-group">
                            <label asp-for="Email" class="col-md-3 control-label text-right"> 邮箱</label>
                            <div class="col-md-9  text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon">*</span>
                                    <input asp-for="Email" class="form-control" validate="{required:true  ,maxlength:50,remote:{url:'../../account/ChkEmail',data:{UserId:function(){return $('#UserId').val(); }}},email:true   }" />
                                </div>
                                <span asp-validation-for="Email" class="text-danger"></span>
                            </div>


                        </div>
                        <div class="form-group">
                            <label asp-for="UserType" class="col-md-3 control-label text-right"> 用户类型</label>
                            <div class="col-md-9  text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon">*</span>
                                    <select class="select2" asp-for="UserType">
                                        @{
                                            var utype = ConvertHelper.ToEnumList(typeof(UserType), false);
                                            if (utype != null && utype.Count > 0)
                                            {
                                                foreach (var item in utype)
                                                {
                                                    @Html.Raw("<option value=\"" + item.Key + "\" " + (item.Key == Model.UserType ? "selected" : "") + ">" + item.Value + "</option>")
                                                }
                                            }
                                        }
                                    </select>
                                </div>
                                <span asp-validation-for="UserType" class="text-danger"></span>
                            </div>


                        </div>
                        <div class="form-group">
                            <label asp-for="RealName" class="col-md-3 control-label text-right"> 真实姓名</label>
                            <div class="col-md-9  text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon">*</span>
                                    <input asp-for="RealName" class="form-control" validate="{required:true  ,maxlength:50   }" />
                                </div>
                                <span asp-validation-for="RealName" class="text-danger"></span>
                            </div>


                        </div>
                        <div class="form-group">
                            <label asp-for="Sex" class="col-md-3 control-label text-right"> 性别</label>
                            <div class="col-md-9  text-left">
                                <div class="input-group m-b text-left">
                                    <span class="input-group-addon">*</span>
                                    <select asp-for="Sex" class="select2 col-md-5">
                                        <option value="1">女</option>
                                        <option value="0">男</option>
                                    </select>
                                </div>
                                <span asp-validation-for="Sex" class="text-danger"></span>
                            </div>


                        </div>
                        <div class="form-group">
                            <label for="Birthday" class="col-md-3 control-label text-right"> 出生日期</label>
                            <div class="col-md-9 text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon"></span>
                                    <input name="Birthday" id="Birthday" class="form-control datetimepicker" value="@(Model.Birthday!=null?Model.Birthday.Value.ToString("yyyy-MM-dd"):"")" asp-format="yyyy-MM-dd" validate="{required:false ,maxlength:23   }" />
                                </div>
                                <span asp-validation-for="Birthday" class="text-danger"></span>
                            </div>


                        </div>
                        <div class="form-group">
                            <label asp-for="Address" class="col-md-3 control-label text-right">地址</label>
                            <div class="col-md-9 ">
                                <div class="input-group m-b">
                                    <span class="input-group-addon"></span>
                                    <input asp-for="Address" class="form-control" validate="{required:false  ,maxlength:50   }" />
                                </div>
                                <span asp-validation-for="Address" class="text-danger"></span>
                            </div>


                        </div>
                        <div class="form-group">
                            <label asp-for="CardNo" class="col-md-3 control-label text-right"> 证件号码</label>
                            <div class="col-md-9 text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon"></span>
                                    <input asp-for="CardNo" class="form-control" validate="{required:false  ,maxlength:50   }" />
                                </div>
                                <span asp-validation-for="CardNo" class="text-danger"></span>
                            </div>


                        </div>
                        <div class="form-group">
                            <label asp-for="TelPhone" class="col-md-3 control-label text-right"> 家庭电话</label>
                            <div class="col-md-9 text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon"></span>
                                    <input asp-for="TelPhone" class="form-control" validate="{required:false  ,maxlength:30   }" />
                                </div>
                                <span asp-validation-for="TelPhone" class="text-danger"></span>
                            </div>


                        </div>
                        <div class="form-group">
                            <label asp-for="QQ" class="col-md-3 control-label text-right">QQ</label>
                            <div class="col-md-9 text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon"></span>
                                    <input asp-for="QQ" class="form-control" validate="{required:false  ,maxlength:30   }" />
                                </div>
                                <span asp-validation-for="QQ" class="text-danger"></span>
                            </div>


                        </div>
                        <div class="form-group">
                            <label asp-for="WebChat" class="col-md-3 control-label text-right"> 微信</label>
                            <div class="col-md-9 text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon"></span>
                                    <input asp-for="WebChat" class="form-control" validate="{required:false  ,maxlength:30   }" />
                                </div>
                                <span asp-validation-for="WebChat" class="text-danger"></span>
                            </div>


                        </div>
                        <div class="form-group">
                            <label asp-for="RegionId" class="col-md-3 control-label text-right"> 区域</label>
                            <div class="col-md-9   text-left">
                                <div class="input-group m-b text-left col-md-12 select2-region-group" data-bind-input="#RegionId">
                                    <span class="input-group-addon"></span>
                                    <input asp-for="RegionId" style="display:none;" validate="{required:true    }" />
                                    <select class="col-md-3 select2-region-group-item"> </select>
                                    <select class="col-md-3 select2-region-group-item"> </select>
                                    <select class="col-md-3 select2-region-group-item">  </select>
                                </div>
                                <span asp-validation-for="RegionId" class="text-danger"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label asp-for="Education" class="col-md-3 control-label text-right"> 学历</label>
                            <div class="col-md-9 text-left">
                                <div class="input-group m-b  text-left">
                                    <span class="input-group-addon"></span>
                                    <select asp-for="Education" class="select2 col-md-5">
                                        <option value="3">高中及以下</option>
                                        <option value="0">大专</option>
                                        <option value="1">本科</option>
                                        <option value="2">研究生</option>
                                        <option value="4">博士生及以上</option>
                                    </select>

                                </div>
                                <span asp-validation-for="Education" class="text-danger"></span>
                            </div>


                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label text-right"></label>
                            <div class="col-md-9 text-left">
                                <div class="i-checks ">
                                    <label asp-for="IsLocked"> <input tabindex="15" asp-for="IsLocked" type="checkbox">  是否锁定 </label>
                                </div>
                            </div>

                        </div>

                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <a class="btn btn-white" asp-action="index">返  回</a>

                                <button class="btn btn-primary" type="submit">保存</button>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

@section scripts{
    <script type="text/javascript">
        $(function () {
            $(document).ready(function () {
                $(".form-horizontal").CustomForm({
                    isValidate: true,
                    isTable: false
                });
                $(".form-horizontal").submit(function () {
                    if (!$(".form-horizontal").valid()) {
                        return false;
                    }
                });
            });
        });
    </script>
}